using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CreatObstacle : MonoBehaviour {
    public GameManger gm;
    public GameObject[] obstacles;
    public Transform spawnPoint;
    public bool docreat = true;
    public float docreatTime = 1f;

    // Start is called before the first frame update
    void Start() {
    }

    // Update is called once per frame
    void Update() {
        if (gm.GameStart && (!gm.PlayerDead))
        if (docreat) {
            int randomIndex = Random.Range(0, obstacles.Length);
            Instantiate(obstacles[randomIndex], spawnPoint.position, spawnPoint.rotation);
            Invoke("Resetdocreat", docreatTime);
            docreat = false;
        }
    }

    public void Resetdocreat() {
        docreat = true;
    }
}
